
/**
 * 是否可以访问目标权限元素
 * @param targetRoleOrPermission 目标(路由|按钮)要求权限
 * @returns {boolean} 满足访问条件
 */
export const hasPermission = (targetRoleOrPermission: string[] | GuardType) => {
  return true;
}

/**
 * 检查是否满足权限
 * @param roleOrPermission 当前用户权限
 * @param target 目标(路由|按钮)要求权限
 * @returns {boolean} 满足访问条件
 */
const can = (roleOrPermission: (string | boolean)[], target: CanType): boolean => {
  let hasRole = false
  const { permission = [], mode = 'oneOf' } = target
  if (mode === 'allOf') hasRole = permission.every((item: string | boolean) => roleOrPermission.includes(item))
  if (mode === 'oneOf') hasRole = permission.some((item: string | boolean) => roleOrPermission.includes(item))
  if (mode === 'except') hasRole = !permission.every((item: string | boolean) => roleOrPermission.includes(item))
  return hasRole
}
